import { GaRegExp, ruleInject, ruleInjectable } from "../InjectionRule";
import { blankRemove } from "../methods/blank-remove";

@ruleInjectable()
export default class ifRule extends GaRegExp {

	@ruleInject() private calcRule!: GaRegExp;

	@ruleInject() private executeRule!: GaRegExp;

	public RuleInit() {
		this.ParseRule([
			"(-", "if", this.Supply("IF"), blankRemove, "\\(", blankRemove, "(", this.calcRule, ")", "\\)", blankRemove, "\\{", "(", this.executeRule, ")", "\\}", blankRemove, ")",
			"(", "else", this.Supply("ELSE_IF"), "\\s", blankRemove, "if", blankRemove, "\\(", blankRemove, "(", this.calcRule, ")", "\\)", blankRemove, "\\{", "(", this.executeRule, ")", "\\}", blankRemove, ")*",
			"(&", "else", this.Supply("ELSE"), blankRemove, "\\{", "(", this.executeRule, ")", "\\}", ")?",
		]);
	}

}
